package cn.tedu.micro.demo.rabbit.controller;

import cn.tedu.micro.demo.rabbit.pojo.DelayMessage;
import cn.tedu.micro.demo.rabbit.produer.AmqpDelayProducer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class SendDelayController {
    @Autowired
    private AmqpDelayProducer<DelayMessage> producer;
    /**
     * 请求方式: get
     * 请求路径:send/delay
     * 请求参数 String username,Integer age(DelayMessage message)
     * 返回: 字符串 send over
     */
    @GetMapping("/send/delay")
    public String sendDelay(DelayMessage delayMessage) {
        //延迟1分钟,deay-ex "" delayMessage 1000*60
        producer.sendDelay("delay_ex","",delayMessage,1000*60);
        log.info("消息发送结束");
        return "send over";
    }
}
